package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {
	engine := gin.Default()

	// GET http://localhost:8080/hello?name=davie&class=软件工程
	engine.GET("/hello", func(context *gin.Context) {
		path := context.FullPath()
		fmt.Println(path)

		var student Student
		err := context.ShouldBindQuery(&student)
		if err != nil {
			log.Fatal(err.Error())
			return
		}
		fmt.Println(student.Name)
		fmt.Println(student.Class)

		context.String(http.StatusOK, "hello ,"+student.Name)

	})

	engine.Run()
}

type Student struct {
	Name  string `json:"name,omitempty" xml:"name" form:"name"`
	Class string `json:"class,omitempty" xml:"class" form:"class"`
}
